package com.taotao.controller;


import com.taotao.common.pojo.EasyUIDataGridResult;
import com.taotao.common.pojo.TaotaoResult;
import com.taotao.pojo.EasyUITreeNode;
import com.taotao.service.ContentCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
public class ContentCategoryController {

    @Autowired
    private  ContentCategoryService contentCategoryService;

    //查询出所有节点
    @RequestMapping(value = "/content/category/list",method = RequestMethod.GET)
    @ResponseBody
    public List<EasyUITreeNode> getContentCategoryList(@RequestParam(value = "id",defaultValue = "0")Long parentId)throws Exception{

        return contentCategoryService.getContentCategoryList(parentId);
    }







    //添加节点

    @RequestMapping(value = "/content/category/create",method = RequestMethod.POST)
    @ResponseBody
    public TaotaoResult createContentCategory(Long parentId,String name)throws Exception{

        return  contentCategoryService.createContentCategory(parentId,name);

    }


    //更新节点

    @RequestMapping(value = "/content/category/update",method = RequestMethod.POST)
    @ResponseBody
    public String updateContentCategory(Long id,String name)throws Exception{
          contentCategoryService.updateContentCategory(id,name);
          return "/content/category/list";
    }

}
